<template lang="">
    <div>
       <subcate  :data='catelist' :cid='course.cid' @scid='getcid'/>
       <van-field v-model="course.name" label="名称" />
       <van-field v-model="course.description" label="描述" />
       <van-field v-model="course.tname" label="讲师" />
       <van-image :src='"http://localhost:5000/static/upload/"+course.pic' width=100 height=100 />
       <video :src='"http://localhost:5000/static/upload/"+i' controls="controls" v-for='i in videos' width=300 height=200></video>
       <br>
       <van-button @click='update'>修改</van-button>
    </div>
</template>
<script>
import subcate from './subcate'
export default {
    components:{
        'subcate':subcate,
    },
    data(){
        return{
            id:this.$route.query.id,
            course:{'name':''},
            catelist:[],
            videos:[]
        }
    },
    methods: {
        getcourse(){
            this.axios.get('courseM?id='+this.id).then(res=>{
                this.course = res.data.course
                //把视频列表转换成json
                this.videos = JSON.parse(res.data.course['vedios'])
            })
        },
         //获取所有分类信息
         getCatelist(){
            this.axios.get('cateM').then(res=>{
                this.catelist = res.data.list
            })
        },
        getcid(id){
            alert(id)
        },
        update(){

        }
    },
    mounted() {
        this.getcourse()
        this.getCatelist()
    },
}
</script>
<style lang="">
    
</style>